package com.candy.dao;

import java.util.*;

public class Test02 {
    public static void main(String[] args) {
        test09();
    }

    public static void test09() {
        Map mp=new TreeMap();
        mp.put("name","张三");
        mp.put("age",25);
        mp.put("hobby","唱歌");
        mp.put("age",22);
//        mp.put(null,null);
//        map的第一种遍历方式
        Set<Map.Entry<String,Object>> s1= mp.entrySet();
        for (Map.Entry<String,Object> ss:s1
        ) {
            System.out.print(ss+"\t");
        }
        System.out.println();
//        map的第二种遍历方式
        Set s2=  mp.keySet();
        for (Object sss:s2
        ) {
            System.out.println("key:"+sss+",value:"+mp.get(sss));
        }





    }

    public static void test08() {
        Map mp=new LinkedHashMap();
//        向map中存放数据
        mp.put("name","张三");
        mp.put("age",25);
        mp.put("hobby","唱歌");
        mp.put("age",22);
        mp.put(null,null);
//        map的第一种遍历方式
        Set<Map.Entry<String,Object>> s1= mp.entrySet();
        for (Map.Entry<String,Object> ss:s1
        ) {
            System.out.print(ss+"\t");
        }
        System.out.println();
//        map的第二种遍历方式
        Set s2=  mp.keySet();
        for (Object sss:s2
        ) {
            System.out.println("key:"+sss+",value:"+mp.get(sss));
        }





    }

    public static void test07() {
        Map mp=new HashMap();
        mp.put("name","张三");
        mp.put("age",25);
        mp.put("hobby","唱歌");
        mp.put("age",22);
        mp.put(null,null);
//        map的第一种遍历方式
       Set<Map.Entry<String,Object>> s1= mp.entrySet();
        for (Map.Entry<String,Object> ss:s1
             ) {
            System.out.print(ss+"\t");
        }
        System.out.println();
//        map的第二种遍历方式
        Set s2=  mp.keySet();
        for (Object sss:s2
             ) {
            System.out.println("key:"+sss+",value:"+mp.get(sss));
        }





    }
    public static void test06() {
        List s1=new LinkedList();
        s1.add("张三");
        s1.add("赵四");
        s1.add("王五");
        s1.add("张三");
        s1.add(null);
        for (Object ss:s1
        ) {
            System.out.println(ss);
        }

    }

    public static void test05() {
        List s1=new ArrayList();
        s1.add("张三");
        s1.add("赵四");
        s1.add("王五");
        s1.add("张三");
        s1.add(null);
        for (Object ss:s1
        ) {
            System.out.println(ss);
        }

    }
    public static void test04() {
//
        Set s1=new TreeSet();
        s1.add("张三");
        s1.add("赵四");
        s1.add("王五");
        s1.add("张三");
//        s1.add(null);
        for (Object ss:s1
        ) {
            System.out.println(ss);
        }

    }
    public static void test03() {
        Set s1=new LinkedHashSet();
        s1.add("张三");
        s1.add("赵四");
        s1.add("王五");
        s1.add("张三");
        s1.add(null);
        for (Object ss:s1
        ) {
            System.out.println(ss);
        }

    }
    public static void test02() {
        Set s1=new HashSet();
        s1.add("张三");
        s1.add("赵四");
        s1.add("王五");
        s1.add("张三");
        s1.add(null);
        for (Object ss:s1
             ) {
            System.out.println(ss);
        }

    }
    public static void test01() {
//        集合
        List ls=new ArrayList();
//        追加元素
        ls.add("张三");
        ls.add(5);
        for (Object l:ls
             ) {
            System.out.println(l);
        }

        Map mp=new HashMap();
        mp.put("name","tom");
        mp.put("sex","M");
        mp.put("age",21);
        mp.put("hobby","唱歌");
//        遍历map需要选转成set，在遍历



    }
}
